package com.atguigu.gmall.order.service;

import com.atguigu.gmall.model.enums.OrderStatus;
import com.atguigu.gmall.model.order.OrderDetail;
import com.atguigu.gmall.model.order.OrderInfo;
import com.atguigu.gmall.order.to.OrderSplitTo;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fasterxml.jackson.core.JsonProcessingException;

import java.util.List;

/**
 * @author lsj
 * @create 2021-08-27 16:02
 */
public interface OrderService extends IService<OrderInfo> {

    boolean checkToken(String userId, String tradeNo);

    /**
     * 校验价格和库存
     * @param orderDetailVoList
     * @return
     */
    List<String> checkSkuPriceAndStock(List<OrderDetail> orderDetailVoList);


    /**
     * 创建订单
     * @param orderInfo
     * @return
     */
    OrderInfo createOrder(OrderInfo orderInfo);

    /**
     * 关闭指定的订单
     * @param id
     */
    void closeOrder(Long id);

    void changeOrderStatusPayed(String out_trade_no, String name);

    /**
     * 查出订单已经订单的详情信息
     * @param outTradeNo
     * @return
     */
    OrderInfo getOrderInfoWithDetailsByOutTradeNo(String outTradeNo);

    /**
     * 按照订单id查询出订单详情
     * @param orderId
     * @return
     */
    OrderInfo getOrderInfoWithDetailsById(Long orderId);

    /**
     * 为库存系统进行拆单
     * @param orderId
     * @param wareSkuMap
     * @return
     */
    List<OrderSplitTo> splitOrder(Long orderId, String wareSkuMap) throws JsonProcessingException;

    /**
     * 修改订单状态
     * @param parseLong
     * @param waitingDelever
     */
    void changeOrderStatus(long parseLong, OrderStatus waitingDelever);
}
